package 简单.将有序数组转为二叉搜索树;


public class Solution1 {
    public TreeNode sortedArrayToBST(int[] nums) {
        return dfs(nums,0,nums.length-1);
    }

    public TreeNode dfs(int[] nums , int lo ,int hi){

        if(lo >hi) return null;
        int mid = lo+(hi-lo)/2;
        TreeNode root = new TreeNode(nums[mid]);

        root.left = dfs(nums,lo,mid-1);
        root.right = dfs(nums,mid+1,hi);
        return root;
    }
}
